import hashlib
import json

class Md5Data:

    def md5_data(self,data):
        if type(data) is dict:
            data1 = json.dumps(data)
            res = hashlib.md5(data1.encode('utf-8'))
            res_data = res.hexdigest()
            print(res_data)
            return res_data
        elif type(data) is str:
            res = hashlib.md5(data.encode('utf-8'))
            res_data = res.hexdigest()
            print(res_data)
            return res_data
        else:
            print("数据类型输入有误，请重新输入")




